#include <stdio.h>
#include <vector>
#include <math.h>
using namespace std;

int main() {
	unsigned int cnt = 0;
	scanf("%d", &cnt);
	for (int i = 0; i < cnt; ++i) {
		unsigned int K = 0;
		scanf("%d", &K);

		const double DD = 8.0 * (double)K - 7.0;
		const double D = sqrt(DD);
		const double n1 = (-1.0 + D) * 0.5;
		const double n2 = (-1.0 - D) * 0.5;

		const bool n1_fits = (n1 > 0) && ( (n1 - floor(n1)) == 0 );
		const bool n2_fits = (n2 > 0) && ( (n2 - floor(n2)) == 0 );

		printf("%s ", ((K == 1) ||n1_fits || n2_fits) ? "1" : "0");
	}

	return 0;
}

